const axios = require("axios")

class MapC {
	static async getLocation(ctx) {
		let {lat,lng,key} = ctx.request.query
		if(!lat){
			lat = 39.984154
		}
		if(!lng){
			lng =116.307490
		}
		if(!key){
			key ="HUUBZ-4NKKB-AZHUC-J7LEC-PJOZS-PIFJP"
		}
		let res = await axios.get(
			`https://apis.map.qq.com/ws/geocoder/v1/?location=${lat},${lng}&key=${key}&get_poi=1`
			)
		if(res.data.status===0){
			ctx.body = {code:0,codeInfo:"成功",data:res.data.result}
		}else{
			ctx.body = {code:1,codeInfo:"失败，请检查参数，再试"}
		}
		
	}
}
module.exports = MapC